package com.gusto.engine.colfil.transformation.impl;

import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;

import com.gusto.engine.colfil.Evaluation;
import com.gusto.engine.colfil.transformation.Transformation;


/**
 * <p>The amplification transformation amplifies the values 
 * and puts more distance between items.<br/>
 * <li>Factors &gt; 1 will amplify values and distances.
 * <li>Factors &lt; 1 will do the inverse job.</p>
 * 
 * @author amokrane.belloui@gmail.com
 *
 */
public class AmplificationTransformation implements Transformation {
	
	private Logger log = Logger.getLogger(getClass());
	
	private double factor;
	
	public AmplificationTransformation(double factor) {
		this.factor = factor;
	}
	
	public List<Evaluation> transform(List<Evaluation> evals) {
		log.info("Applying Amplification Transformation");
		double norm;
		
		List<Evaluation> res = new ArrayList<Evaluation>(); 
		for (Evaluation e : evals) {
			if (e.getValue() > 0) {
				norm = Math.pow(e.getValue()+1, factor) - 1;
			}
			else {
				norm = -Math.pow(-e.getValue()+1, factor) + 1;
			}
			e.setValue(norm);
			res.add(e);
		}
		return res;
	}

}
